package cn.virens.cmpt.rabbit;

import cn.virens.cmpt.rabbit.packet.Packet;

public abstract class RabbitConsumerHandler<T extends Packet> {

	public boolean isSupport(String cmd) {
		return false;
	}

	public boolean doHandler(RabbitConsumerProps prop, String body) {
		return body != null && doHandler0(prop, createPacket(body));
	}

	public boolean doHandler0(RabbitConsumerProps prop, T packet) {
		return true;
	}

	protected T createPacket(String body) {
		return null;
	}

	@SuppressWarnings("unchecked")
	protected boolean doHandler0(Packet packet) {
		return doHandler0(null, (T) packet);
	}

}
